package com.wjy.Data_Structure.linearlist.common;

import com.wjy.Data_Structure.linearlist.enity.Student;
import com.wjy.Data_Structure.strategy.Strategy;

public class StudentStrategy implements Strategy {

	@Override
	public boolean equal(Object obj1, Object obj2) {
		if (obj1 instanceof Student && obj2 instanceof Student) {
			Student s1 = (Student) obj1;
			Student s2 = (Student) obj2;
			return s1.getSId().equals(s2.getSId());
		} else {
			return false;
		}
	}

	@Override
	public int compare(Object obj1, Object obj2) {
		if (obj1 instanceof Student && obj2 instanceof Student) {
			Student s1 = (Student) obj1;
			Student s2 = (Student) obj2;
			return s1.getSId().compareTo(s2.getSId());
		} else {
			return obj1.toString().compareTo(obj2.toString());
		}
	}

}
